<template>
  <div class="main">
    <div class="headers">
			<span class="fl">立信个税精灵后台管理系统</span>
			<ul class="nav">
				<li class="fl" v-for="(item,index) in navList" @click="goNav(item,index)" :class="[index==curIndex?'active':'']">{{item.name}}</li>
			</ul>
			<div  class="fr right" @click="loginOut()">
	      <span>退出</span>
	    </div>
		</div>
		<div class="content"><router-view/></div>
		<div class="footer"><a target="_blank" href="http://beian.miit.gov.cn/">备案/许可证编号：渝ICP备17012265号-4</a></div>
  </div>
</template>
<script>
	export default {
    name:'main',
    data: function(){
      return{
        navList:[
		    	{name:"政策发布",url:"/main/policyRelease"},
		    	{name:"案例发布",url:"/main/casePublishing"},
		    	{name:"洞察发布",url:"/main/insight"},
		    	{name:"轮播发布",url:"/main/carousel"},
		    	{name:"问题库",url:"/main/questionBank"},
		    	{name:"数据字典",url:"/main/dataDictionary"},
		    ],
		    curIndex:0
      }
    },
    created: function(){
	    if(this.$route.path=="/main/policyRelease"||this.$route.path=="/main/createPublishing"){
	    	this.curIndex=0;
	    }else if(this.$route.path=="/main/casePublishing"||this.$route.path=="/main/createCase"){
	    	this.curIndex=1;
	    }else if(this.$route.path=="/main/insight"||this.$route.path=="/main/createInsight"){
	    	this.curIndex=2;
	    }else if(this.$route.path=="/main/carousel"){
	    	this.curIndex=3;
	    }else if(this.$route.path=="/main/questionBank"||this.$route.path=="/main/createQuestion"){
	    	this.curIndex=4;
	    }else if(this.$route.path=="/main/dataDictionary"){
	    	this.curIndex=5;
	    }
	    this.set("curIndex",this.curIndex);
	  },
	  methods:{
	    goNav: function(item,index) {
	    	this.curIndex=index;
	    	this.set("curIndex",index);
	    	this.$router.push({path:item.url});
	    },
	    loginOut:function(){
	    	var _this=this;
	    	var indexs=layer.confirm("您确定要退出吗？", {
					title:"退出",
					btnAlign:"c",
				  btn: ['确定','取消'] //按钮
				}, function(){
		    	_this.$post(
			      '/user/outUser',
			      {
			        user:_this.get("userName")
			      }
		      ).then(response => {
		      	layer.close(indexs);
	        	_this.clear();
	         	_this.$router.push({path: '/login'});
		     	}).catch(err => {
				  	console.log(err)
					})
		    })
	    }
	  },
	}
</script>
<style lang="less" scoped>
	.content{
		margin-bottom: 50px;
	}
	.footer{
		text-align: center;
		color: #999;
		height: 50px;
		line-height: 50px;
		position: fixed;
		bottom: 0;
		width:100%;
		background: #fff;
		z-index: 10;
	}
	.footer>a{
		color:#999;
		text-decoration: none;
	}
	.footer:hover>a{
		color: #00307c;
	}
</style>